﻿using Bootstrap.Data;
using Bootstrap.Definition.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Bootstrap.Control;
namespace Bootstrap.Demo
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (ThumbnailList.InnerList == null)
                ThumbnailList.InnerList = new List<BootstrapThumbnail>();

            var list= PostData.GetPostList();
            var category = Request.QueryString["Category"];

            var categoryList = string.IsNullOrEmpty(category)?list: list.Where(q => q.Category.ToLower().Equals( category.ToLower())).ToList();

            foreach (var item in categoryList)
            {
                ThumbnailList.InnerList.Add(new BootstrapThumbnail()
                {
                    HeaderText=item.Title,
                    Text=item.ShortDescription,
                    ImageUrl=item.ImageUrl,
                    OnClientClick="onThumbnailClick($(this));"
                });
            }
        }
    }
}